/*** 
 * @Author: pengcheng
 * @Date: 2021-06-24 10:27:50
 * @LastEditTime: 2021-08-25 09:09:45
 * @LastEditors: pengcheng
 * @Description: 
 * @FilePath: /kylin-daq/src/LogCheck.h
 */
#ifndef LOGCHECK_H
#define LOGCHECK_H

#include <QtCore/QtCore>

class LogCheck: public QThread
{
    Q_OBJECT
public:
private:
    //  最大文件数目(个)
    static constexpr int32_t s_maxFileNum = 5;
    //  单个文件最大字节(Byte)
    static constexpr int32_t s_maxByteNum = 100 * 1024 * 1024;
    //  检测时间(Ms)
    static constexpr int32_t s_checkIntervalMSec = 60 * 60 * 1000;
    // static constexpr const char *s_logBaseFolderPath = "/var/log/";
    static constexpr const char *s_logBaseFolderPath = "/.log/";
    static QScopedPointer<LogCheck> ms_instance;
    // QScopedPointer<QTimer> m_timer;
    QString m_appName;
    QString m_logDirPath;
public:
    static LogCheck *instance(void);
    static void init(const QString &strAppName);
    ~LogCheck();
protected:
    explicit LogCheck(QObject *parent = nullptr);
private:
    void checkFile(void);
    void checkFileNum(void);
    void checkFileSize(void);
    void doInit(const QString &strAppName);
    void run() override;
signals:
};

#endif // LOGCHECK_H
